package com.turbo.cloud.bpm.web.webservice;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.turbo.cloud.bpm.web.logic.FlwGroupLogic;
import com.turbo.cloud.bpm.web.model.custom.CustomFlwGroupDO;
import com.turbo.cloud.bpm.web.model.custom.CustomFlwGroupQO;
import com.turbo.cloud.bpm.web.model.custom.CustomFlwGroupVO;
import com.turbo.cloud.core.api.R;
import com.turbo.cloud.core.api.Result;
import com.turbo.cloud.core.base.PageQuery;
import com.turbo.cloud.core.validated.InsertValidated;
import com.turbo.cloud.core.validated.UpdateValidated;
import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 流程组表 前端控制器
 * </p>
 *
 * @author zhangluning
 */
@RequiredArgsConstructor
@RestController
public class CustomFlwGroupController {

    final FlwGroupLogic flwGroupLogic;

    /**
     * 查询流程组分页列表
     *
     */
    @PostMapping(name = "查询流程组分页列表", value = "/webservice/flwGroup/queryFlwGroupPage")
    public Result<Page<CustomFlwGroupVO>> queryFlwGroupPage(@RequestBody PageQuery<CustomFlwGroupQO> pageQuery) {
        Page<CustomFlwGroupVO> result = flwGroupLogic.queryFlwGroupPage(pageQuery);
        return R.result(result);
    }

    /**
     * 新增流程组
     *
     * @param customFlwGroupDO 实体
     */
    @PostMapping(name = "新增流程组", value = "/webservice/flwGroup/createFlwGroup")
    public Result<Boolean> createFlwGroup(@RequestBody @Validated(InsertValidated.class) CustomFlwGroupDO customFlwGroupDO) {
        boolean result = flwGroupLogic.createFlwGroup(customFlwGroupDO);
        return R.result(result);
    }

    /**
     * 修改流程组
     *
     * @param customFlwGroupDO 实体
     */
    @PostMapping(name = "修改流程组", value = "/webservice/flwGroup/modifyFlwGroup")
    public Result<Boolean> modifyFlwGroup(@RequestBody @Validated(UpdateValidated.class) CustomFlwGroupDO customFlwGroupDO) {
        boolean result = flwGroupLogic.modifyFlwGroup(customFlwGroupDO);
        return R.result(result);
    }

    /**
     * 删除流程组
     *
     * @param id 流程组ID
     */
    @GetMapping(name = "删除流程组", value = "/webservice/flowGroup/removeFlwGroupById")
    public Result<Boolean> removeFlwGroupById(@NotBlank(message = "流程组ID不能为空") String id) {
        boolean result = flwGroupLogic.removeFlwGroupById(id);
        return R.result(result);
    }

    /**
     * 开启、关闭流程组有效状态
     *
     * @param id 流程组ID
     */
    @GetMapping(name = "开启、关闭流程组有效状态", value = "/webservice/flowGroup/enabledFlwGroupStateById")
    public Result<Boolean> enabledFlwGroupStateById(@RequestParam @NotBlank(message = "流程组ID不能为空") String id) {
        boolean result = flwGroupLogic.enabledFlwGroupStateById(id);
        return R.result(result);
    }
}
